require 'forwardable'
require 'json'
require 'spoule/json'

module Spoule
  class Enums
    include Spoule::Json
    extend Forwardable

    def_delegators :@enums, :<<, :size, :each

    def initialize
      @enums = []
    end

    def to_json(*opts)
      s  = ''
      if @enums.size > 0
        s += "," + _format_json_array('enum', @enums.collect{|x| x.name}, opts)
        s += ',' + _format_json_array('enumDescriptions', @enums.collect{|x| x.description}, opts)
      end
      return s
    end
  end
end # module Spoule
